using UnityEngine;

namespace RGuang.PlathformCtrl
{
    [CreateAssetMenu(menuName = "Data/StateMachine/PlayerState/JumpUp", fileName = "PlayerState_JumpUp")]
    public class PlayerState_JumpUp : PlayerState
    {
        [SerializeField] float jumpForce = 7f;//跳起的力
        [SerializeField] float moveSpeed = 5f;//跳起时移动速度
        [SerializeField] ParticleSystem jumpVFX;
        [SerializeField] AudioClip jumpSFX;
        [SerializeField] float stayJumpUpTime = 1f;
        public override void Enter()
        {
            base.Enter();
            player.VoicePlayer.PlayOneShot(jumpSFX);
            input.HasJumpInputBuffer = false;
            player.SetVelocityY(jumpForce);
            Instantiate(jumpVFX, player.transform.position, Quaternion.identity);
        }

        public override void LogicUpdate()
        {
            if (input.StopJump || player.IsFalling || stateDuration > stayJumpUpTime)
            {
                stateMachine.SwitchState(typeof(PlayerState_Fall));
            }
        }

        public override void PhysicUpdate()
        {
            player.Move(moveSpeed);
        }
    }

}
